package com.gaoyi.crm.util;

import android.content.Context;
import android.util.TypedValue;

public class DensityUtil {

    public static int dp2px(float dp) {
        float scale = AppUtil.getContext().getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }

    public static float getSPValue(Context context,int size){
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,size,context.getResources().getDisplayMetrics());
    }

    public static float getDPValue(Context context,int num){
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,num,context.getResources().getDisplayMetrics());
    }
}
